package com.st.service.impl;

import com.st.dao.IGoodsDao;
import com.st.dao.IProductCategoryDao;
import com.st.entity.Goods;
import com.st.service.IGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class GoodsService implements IGoodsService {
    @Autowired
    private IGoodsDao goodsDao;

    @Override
    public List<Goods> query(Goods goods) {
        return goodsDao.query(goods);
    }

    @Override
    public Integer add(Goods goods) {
        return goodsDao.add(goods);
    }

    //商品下架
    @Override
    public Integer goodsDown(String ids) {
        Map<String, String> map = new HashMap<>();
        map.put("goodsStatus", "0");
        map.put("ids", ids);
        return goodsDao.updateStatus(map);
    }

    @Override
    public Integer update(Goods goods) {
        return goodsDao.update(goods);
    }

    @Override
    public Integer goodsAbove(String ids) {
        Map<String, String> map = new HashMap<>();
        map.put("goodsStatus", "1");
        map.put("ids", ids);
        return goodsDao.updateStatus(map);
    }

    @Override
    public Integer del(Integer id) {
        return goodsDao.del(id);
    }

    @Override
    public List<Goods> queryNew() {
        return goodsDao.queryNew();
    }
}
